﻿using Mes.Domain.BoundedContext.Entities.WorkOrders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class JobExecEntityConfig : IEntityTypeConfiguration<JobExec>
    {
        public void Configure(EntityTypeBuilder<JobExec> builder)
        {
            builder.ToTable("job_exec");
            builder.HasKey(b => new { b.Row_Id });
            builder.Property(b => b.Ent_Id).IsRequired();
            builder.Property(b => b.Job_Pos).IsRequired();
            builder.Property(b => b.Next_Job_Only).IsRequired();
            builder.Property(b => b.Item_Based_Desc).IsRequired();
            builder.Property(b => b.Job_End_Confirm_Msg).HasMaxLength(80);
            builder.Property(b => b.Def_To_Ent_Id);
            builder.Property(b => b.Def_Reject_Ent_Id);
            builder.Property(b => b.Def_From_Ent_Id);
            builder.Property(b => b.Def_Prod_Reas_Cd).IsRequired();
            builder.Property(b => b.Def_Cons_Reas_Cd);
            builder.Property(b => b.Def_Lot_No).HasMaxLength(40);
            builder.Property(b => b.Def_Sublot_No).HasMaxLength(40);
            builder.Property(b => b.Autoload_Job_Specs).IsRequired();
            builder.Property(b => b.Auto_Seq_Start_Option).IsRequired();
            builder.Property(b => b.Auto_Job_Start_Option).IsRequired();
            builder.Property(b => b.Auto_Job_End_Option).IsRequired();
            builder.Property(b => b.Incl_Class_Reas).IsRequired();
            builder.Property(b => b.Must_Complete_Steps).IsRequired();
            builder.Property(b => b.Must_Prod_Reqd_Qty).IsRequired();
            builder.Property(b => b.Local_Movable_Cons_Ent).IsRequired();
            builder.Property(b => b.Local_Movable_Prod_Ent).IsRequired();
            builder.Property(b => b.Run_Without_Operator).IsRequired();
            builder.Property(b => b.Apply_Post_Exec_Fc_Counts).IsRequired();
            builder.Property(b => b.Suppress_Start_Qty_Prompt).IsRequired();
            builder.Property(b => b.Allow_Zero_Qty_Split).IsRequired();
            builder.Property(b => b.Auto_Alloc_Qty_To_Running_Job).IsRequired();
            builder.Property(b => b.Cur_Wo_Id).HasMaxLength(40);
            builder.Property(b => b.Cur_Oper_Id).HasMaxLength(40);
            builder.Property(b => b.Cur_Step_No);
            builder.Property(b => b.Cur_Step_Grp_Id);
            builder.Property(b => b.Cur_Step_Start);
            builder.Property(b => b.Spare1).HasMaxLength(1000);
            builder.Property(b => b.Spare2).HasMaxLength(1000);
            builder.Property(b => b.Spare3).HasMaxLength(1000);
            builder.Property(b => b.Spare4).HasMaxLength(1000);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).IsRequired().HasMaxLength(40);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
